import 'dart:io';
import 'dart:typed_data';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:photo_view/photo_view.dart';

import 'kb_progress_indicator.dart';

///图片预览界面
class NetImagePreviewPage extends StatelessWidget {
  final List<String> listPath;
  final int index;
  NetImagePreviewPage({
    Key key,
    this.listPath,this.index = 0
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.transparent,
      child: Container(
        alignment: Alignment.center,
        color: Colors.black,
        child: Swiper(
          index: this.index,
          itemCount: listPath.length,
          itemBuilder: (context,index){
            String path = listPath[index];
            return Container(
              child: GestureDetector(
                onTap: () {
                  Navigator.of(context).pop();
                },
                child: PhotoView(
                  loadingBuilder: (context,event){
                    return Center(
                      child: Container(
                        width: 50,
                        height: 50,
                        child: KbProgressIndicator(),
                      ),
                    );
                  },
                  imageProvider: NetworkImage(path),
                ),
              ),
            );
          },
        )
      ),
    );
  }
}
